package com.fanbuchi.app.ins.image;

import android.net.Uri;
import android.util.DisplayMetrics;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.fanbuchi.app.ins.utils.ScreenHelper;

/**
 * Created by rabbit on 2016/3/16.
 */
public class ImageManager {
    //repalce host holder.header.setImageURI(uri);
    public static void showThumb(Uri uri, SimpleDraweeView draweeView){
        DisplayMetrics displayMetrics= ScreenHelper.getScreenInfo();

        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(displayMetrics.widthPixels, displayMetrics.heightPixels))
                .build();

        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener<ImageInfo>())
                .build();
        draweeView.setController(controller);
    }

}
